<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>localStorage</title>
</head>
<body>
    <script>
        function saveData() {
            let p = {
                name: '小明',
                age: 11,
                sex: '男'
            }
            window.localStorage.setItem('person', JSON.stringify(p))
            window.localStorage.setItem('name', '小明')
            window.localStorage.setItem('age', '11')
        }
        function getData() {
            let p = JSON.parse(window.localStorage.getItem('person'))
            console.log(p)
            console.log(window.localStorage.getItem('name'))
            console.log(window.localStorage.getItem('age'))
        }
        function deleteData() {
            window.localStorage.removeItem('person')
        }

        function clearAllData() {
            window.localStorage.clear()
        }
    </script>
    <button onclick="saveData()">点我保存一个数据</button>
    <button onclick="getData()">点我读取一个数据</button>
    <button onclick="deleteData()">点我删除一个数据</button>
    <button onclick="clearAllData()">点我清空数据</button>
</body>
</html>